<?php
/*********************************************************************\
* This File is a part of BH-PANEL (Breizh-Heberg Panel v2.1)
* Copyright (C) 2008-2009 the BH Developpers : Vincent Giersch <mail@vincordi.fr>, Cyprien Laleau <fanning.fr@gmail.com> and Edwin Cabiten <marmottes44@hotmail.fr>
* See file AUTHORS to get more informations

* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.

* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.

* You should have received a copy of the GNU General Public License
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
/*********************************************************************/


define('CONFIG_ROOT', '/etc/bh/');
define('CODE_ROOT', '/opt/hosting/daemons/includes/');
define('CURRENT_SERVER', 3);
define('PARTITION', '/');
define('APACHE_CONF', CONFIG_ROOT.'serveurs/data_apache/_apache2.conf');
include CODE_ROOT."common.php";
//////////////////////////////////////////////////////
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=utf-8\n";
$headers .= "From: Breizh Héberg Bot <robot@breizh-heberg.net>\n";
$headers .= "Reply-To: Support Breizh-Héberg <support@breizh-heberg.net>\n";
//////////////////////////////////////////////////////
// --------------------------- Comptes  d'Hébergement
$liste_ = query("SELECT 
				comptes_heberg.*,
				users.u_nic,
				users.u_email
				FROM comptes_heberg
				LEFT JOIN users
				ON comptes_heberg.u_nic = users.u_nic
				WHERE comptes_heberg.etat = '1' AND comptes_heberg.serveur_apache = '".CURRENT_SERVER."'");
While($liste = mysql_fetch_array($liste_)) {
	$nb = shell_exec("cat /var/log/mail.log | grep \"postfix/pickup\" | grep \"".$liste['user_linux']."\" | awk '{MAILS=MAILS+1} END { print MAILS }'");
	trim($nb) == "" ? $nb = 0 : false;
	if($nb > 2500)  {
		query("UPDATE comptes_heberg SET etat = 3 WHERE id = '".$liste['id']."'");
		$mail_content = array();
		$mail_content['{title}'] = "Spam - Compte \"".$liste_['user_linux']."\"";
		$mail_content['{contenu}'] = "Notre service de mails a détecté une utilisation abusive de notre service de mails. Votre compte a été suspendu temporairement. Vous pouvez contacter un administrateur pour plus d'informations.";
		$mail = str_replace(array_keys($mail_content), array_values($mail_content), file_get_contents("/etc/bh/tpl/mail-default.html"));
		mail($liste['u_email'], '[Breizh Héberg] '.$mail_content['{title}'], $mail, $headers);
	}
	query("UPDATE comptes_heberg SET out_mails = '".$nb."' WHERE id = '".$liste['id']."'");
}
deconnexionbdd();
?>
 
